<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ page language="java"
	import="java.util.HashMap,java.lang.*,java.sql.Date,java.util.*,java.text.SimpleDateFormat"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<fmt:setBundle basename="ApplicationResources" />
<script language="javascript" type="text/javascript"
	src="../script/datetimepicker.js"></script>
<script type="text/javascript" src="../script/jquery.js"></script>
<script type="text/javascript" language="javascript">
function validateCopy(){
	var isValid = true;
	var frmdatestr = $("#fromdate").attr("value");
	var todatestr = $("#todate").attr("value");
	if(frmdatestr == null || todatestr == null){
		document.getElementById("copyErrorMsg").innerHTML = "Please fill the required field!";
		isValid = false;
	}
	else{
		var currDate = new Date();
		var temp = todatestr.split("-", todatestr.length - 1);
		var toDate = new Date(temp[2], temp[1]-1, temp[0],0,0,0);
		if(toDate < currDate ){
			document.getElementById("copyErrorMsg").setAttribute('style', 'color:red');
			document.getElementById("copyErrorMsg").innerHTML = "Cannot copy schedule for past date!";
			isValid = false;
		}
	}
	return isValid;
}	
</script>
<title><fmt:message key="label.crudschedule.add" /></title>
</head>
<body>
	<h1>Copy Schedule</h1>
	<form action="${pageContext.request.contextPath}/ScheduleController/copySchedule"
			method=post onSubmit="return validateCopy()">
		<table cellpadding=4 cellspacing=2 border=0 align="left">
			<tr><%SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy");
				Calendar cal = Calendar.getInstance(); %>		
				<td>Copy Program Slot From</td><td>:</td>
				<td><input id="fromdate" name="fromdate" type="text" size="25" readonly="readonly" value="<%=format.format(new Date(cal.getTime().getTime()))%>"> 
				<a	href="javascript:NewCal('fromdate','ddmmyyyy')"> <img
						src="../img/cal.gif" width="16" height="16" border="0"
						alt="Pick a date">
				</a></td>
			</tr>
			<tr>
				<td>Copy Program Slot To</td><td>:</td>				
		        <%cal.add(Calendar.DATE, 7); %>
				<td align="right"><input id="todate" name="todate" type="text"
					size="25" readonly="readonly" value="<%=format.format(new Date(cal.getTime().getTime()))%>"> <a
					href="javascript:NewCal('todate','ddmmyyyy')"> <img
						src="../img/cal.gif" width="16" height="16" border="0"
						alt="Pick a date">
				</a></td>
			</tr>
			<tr>
				<td><input type="submit" value="Submit" onClick="return validateCopy()"></td>
				<td></td>
				<td><div id="copyErrorMsg"></div></td>
			</tr>
		</table>
	</form>
</body>
</html>